<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    // 工厂模式
    // function createCar(c, b){
    //     this.color = c;
    //     this.brand = b;
    // }
    // const c1 = new createCar("白色", "大众");
    // console.log(c1);
    // const c2 = new createCar("白色", "大众");
    // console.log(c2);
    // const c3 = new createCar("红色", "大众");
    // console.log(c3);
    // const c4 = new createCar("黑色", "大众");
    // console.log(c4);

    // 工厂模式
    function createCar(c, b){
        this.color = c;
        this.brand = b;
    }

    // 抽象工厂模式
    function createDzCar(c){
        return new createCar(c, "大众");
    }

    const c1 = createDzCar("白色");
    console.log(c1);
    const c2 = createDzCar("红色");
    console.log(c2);
    const c3 = createDzCar("黑色");
    console.log(c3);
    const c4 = createDzCar("白色");
    console.log(c4);
    const c5 = createDzCar("蓝色");
    console.log(c5);

    
</script>
</html>